package com.jl.sms.cdma;

import java.util.Arrays;

public class ParameterFactory {
	
	public static Parameter newInstance(byte[] data, int offset){
		int length = (data[offset + 1] & 0xFF) + 2;
		return newInstance(Arrays.copyOfRange(data, offset, offset + length));
	}

	public static Parameter newInstance(byte[] value) {
		byte ID = value[0];
		switch (ID) {
		case TeleserviceIdentifier.ID:
			if(value.length != 2){
				return null;
			}else{
				return new TeleserviceIdentifier(value);
			}
		case CDMA.ADDRESS_Destination:
		case CDMA.ADDRESS_Originating:
			return new Address(value);
		case BearerData.ID:
			return new BearerData(value);
		default:
			break;
		}
		
		return null;
	}
	
}
